<template>
	<view class="container">
		<view class="content">
			<!-- 顶部是管理员操作选项，权限足够才可以显示 -->
			<!-- 项目列表九宫格 -->
			<view class="example-body">
				<uni-grid :column="3" :highlight="true" @change="change">
					<uni-grid-item v-for="(item, index) in gongzuotaishouye_data.work_items" :key="index">
						<image :src="item.img_src" class="image" mode="aspectFill" ></image>
						<text class="text">{{ item.text }}</text>
					</uni-grid-item>
				</uni-grid>
			</view>
		</view>
	</view>
</template>

<script>
	import uniGrid from '@/components/uni-grid/uni-grid.vue'
	import uniGridItem from '@/components/uni-grid-item/uni-grid-item.vue'
	export default {
		components: {
			uniGrid,
			uniGridItem
		},
		data() {
			return {
				gongzuotaishouye_data: {}
			}
		},
		async onLoad(option) {
			// let params = {
			// 	"canshu1": this.gongzuotaishouye_data.canshu1
			// };
			// upload_data(params, 'GET', this.$api.Apiurl.gongzuotaishouye_urlData.url, (res) => {
			// 	if (res.data.code == 1) {
			// 		this.gongzuotaishouye_data = this.$api.Json.gongzuotaishouye_data;
			// 	} else {
			// 		msg(res.data.msg);
			// 	}
			// });
			// this.gongzuotaishouye_data.canshu1 = option.canshu1;
			this.gongzuotaishouye_data = await this.$api.json('gongzuotaishouye_data');
			console.log(JSON.stringify(this.gongzuotaishouye_data));
		},
		onShow() {
			// let params = {
			// 	"canshu1": this.gongzuotaishouye_data.canshu1
			// };
			// upload_data(params, 'GET', this.$api.Apiurl.gongzuotaishouye_urlData.url, (res) => {
			// 	if (res.data.code == 1) {
			// 		this.gongzuotaishouye_data = this.$api.Json.gongzuotaishouye_data;
			// 	} else {
			// 		msg(res.data.msg);
			// 	}
			// });
			// this.gongzuotaishouye_data = await this.$api.json('gongzuotaishouye_data');
			// console.log(JSON.stringify(this.gongzuotaishouye_data));

		},
		methods: {
			change(e) {
				let {
					index
				} = e.detail
				console.log(index)
				let link_url = this.gongzuotaishouye_data.work_items[index].url;
				uni.navigateTo({
					url:link_url
				})
			}
		}
	}
</script>

<style>
	.image {
		width: 50upx;
		height: 50upx;
	}

	.text {
		font-size: 26upx;
		margin-top: 10upx;
	}
</style>
